﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sharp.DataTransferObject;
using Sharp.Portal.Interface;
using Sharp.WebBooter.Areas.Platform.Models;

namespace Sharp.WebBooter.Areas.Workflow
{

    /// <summary>
    /// 安装
    /// </summary>
    public class Install : INavigation
    {
        /// <summary>
        /// 导航
        /// </summary>
        /// <returns></returns>
        /// <remarks>导航即权限数据</remarks>
        public IList<PermissionDTO> Navigation()
        {
            var permissionData = new List<PermissionDTO>();
            var platformData =
                   new List<PermissionDTO>()
                   {

new PermissionDTO("005", "流程", 1, "", "fa fa-id-badge"){IsShortcut=true},
new PermissionDTO("005001", "流程设计", 1, "/Workflow/Process/Index", "fa fa-superpowers"),
new PermissionDTO("005002", "已处理流程", 2, "/Workflow/Task/Completed", "fa fa-window-restore"),
new PermissionDTO("005003", "待处理流程", 3, "/Workflow/Task/Index", "fa fa-window-maximize"),


                   };
            platformData.ForEach(x =>
            {
                x.SystemCode = "Workflow";
                x.Id = Guid.Parse($"{x.Code}_{x.SystemCode}_{x.Category}".Md5());
                var parent = platformData.FirstOrDefault(c =>
                    c.SystemCode == x.SystemCode &&
                    x.Code.StartsWith(c.Code) &&
                    c.Code.Length == x.Code.Length - 3);
                if (parent != null)
                {
                    x.ParentId = parent.Id;
                }
                else
                {
                    x.ParentId = null;
                }
            });
            permissionData.AddRange(platformData);

            return permissionData;
        }

        public bool IsDevOnly { get; set; }
    }
}